package com.penghk.learn

import org.apache.spark.{SparkConf, SparkContext}

object WordCount {

  def main(args: Array[String]): Unit = {
    val conf = new SparkConf();
    conf.setMaster("local");
    conf.setAppName("wordCount");
    val sc = new SparkContext(conf)
    val textRDD = sc.textFile("file:///usr/local/spark-2.3.0/README.md")
    val result = textRDD.flatMap(_.split(' ')).map((_, 1)).reduceByKey(_ + _).collect()
    result.foreach(println)
  }
}
